﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
namespace QuanLyKhachSan
{
    public partial class frmDangKyThuePhong : DevExpress.XtraEditors.XtraForm
    {
         DataClassesKhachSanDataContext db = new DataClassesKhachSanDataContext(SystemInfo.pub_ConnString);
         String khid = "";
         DataTable dtKH = new DataTable();
         DataTable dtPhong = new DataTable();
         public frmQuanLyThuePhong frmquanlythuephong;
         public frmSoDoPhong frmsodo;
         static bool testPhong = false  ;
         public bool testThuePhongtusodo = false, testThuePhongTuQuanLyThuePhong = false ;
         public int PhongID; 
    
        public frmDangKyThuePhong()
        {
            InitializeComponent();
        }

        private void txtCMND_Leave(object sender, EventArgs e)
        {
            if (txtCMND.Text != "" && txtKhachHang.Text != "")
            {
                var testkhachhang = from kh in db.KHACH_HANGs where kh.KH_CMND == txtCMND.Text select kh;

                if (testkhachhang.Count() == 1)
                {
                    var khachhang = testkhachhang.Single();
                    if (txtKhachHang.Text.ToLower() != khachhang.KH_HOTEN.ToLower())
                    {
                        MessageBox.Show("CMND đã được tồn tại với tên: " + khachhang.KH_HOTEN);
                        txtDienThoai.Properties.ReadOnly = false;
                        txtDiaChi.Properties.ReadOnly = false;
                    }
                    else
                    {
                        txtDienThoai.Text = khachhang.KH_DIENTHOAI;
                        txtDienThoai.Properties.ReadOnly = true;
                        txtDiaChi.Text = khachhang.KH_DIACHI;
                        txtDiaChi.Properties.ReadOnly = true;
                        khid = khachhang.KH_ID.ToString ();
                    }
                }
                else
                {
                    //MessageBox.Show("Thêm vào dữ liệu thôi");
                }
            }
        }

        private void radioGroup1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        private void txtKhachHang_Leave(object sender, EventArgs e)
        {
            txtCMND_Leave(sender, EventArgs.Empty);
        }

        private void frmDangKyThuePhong_Load(object sender, EventArgs e)
        {
            dtKH.Columns.Add("KH_ID");
            dtKH.Columns.Add("KH_HOTEN");
            dtKH.Columns.Add("KH_CMND");
            dtKH.Columns.Add("KH_DIACHI");
            dtKH.Columns.Add("KH_DIENTHOAI");
            dtKH.Columns.Add("P_ID");
          

            this.createDtPhong();

            this.fillDataRepLookup();

            if (radioGroup2.SelectedIndex == 0)
            {
                if (deNgayDen.Text != "" && deNgayDi.Text != "")
                {
                    this.fillCbPhong();
                }
            }
           
        }

        public void fillDataRepLookup()
        {

            DataClassesKhachSanDataContext db1 = new DataClassesKhachSanDataContext(SystemInfo.pub_ConnString);

            var khachhang = db1.KHACH_HANGs;

            repLoHoTenKH.DataSource = khachhang;
            repLoHoTenKH.DisplayMember = "KH_HOTEN";
            repLoHoTenKH.ValueMember = "KH_ID";

            repLoCmndKH.DataSource = khachhang;
            repLoCmndKH.DisplayMember = "KH_CMND";
            repLoCmndKH.ValueMember = "KH_ID";

            repLoDiaChiKH.DataSource = khachhang;
            repLoDiaChiKH.DisplayMember = "KH_DIACHI";
            repLoDiaChiKH.ValueMember = "KH_ID";

            repLoDienThoaiKH.DataSource = khachhang;
            repLoDienThoaiKH.DisplayMember = "KH_DIENTHOAI";
            repLoDienThoaiKH.ValueMember = "KH_ID";

        }

        void createDtKhachHang()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("KH_ID");
            dt.Columns.Add("KH_HOTEN");
            dt.Columns.Add("KH_CMND");
            dt.Columns.Add("KH_DIACHI");
            dt.Columns.Add("KH_DIENTHOAI");
            gcKH.DataSource = dt;  
        }
        void createDtPhong()
        {

            dtPhong.Columns.Add("P_MA");
            dtPhong.Columns.Add("LP_LOAI");
            dtPhong.Columns.Add("CP_CO");
            dtPhong.Columns.Add("KV_TEN");
            dtPhong.Columns.Add("GIA");
            dtPhong.Columns.Add("P_ID");
            gridControlChiTietDatPhong .DataSource = dtPhong;
        }
        void fillCbPhong()
        {
            var phong = db.Kiem_tra_Dat_phong(DateTime.Parse(deNgayDen.EditValue.ToString()), DateTime.Parse(deNgayDi.EditValue.ToString()));
            lePhong.Properties.DataSource = phong;
            lePhong.Properties.DisplayMember = "P_MA";
            lePhong.Properties.ValueMember = "P_ID";
            
            if (testThuePhongtusodo == true )
            {
                lePhong.EditValue = PhongID ;
            }
            else
            {
                lePhong.ItemIndex = 0;
            }
            

        }

        private void deNgayDen_EditValueChanged(object sender, EventArgs e)
        {
            if (radioGroup2.SelectedIndex == 0)
            {
                if (deNgayDen.Text != "" && deNgayDi.Text != "")
                {
                    this.fillCbPhong();
                }
            }
            else
            {
 
            }
           
        }

        private void deNgayDi_EditValueChanged(object sender, EventArgs e)
        {
            if (radioGroup2.SelectedIndex == 0)
            {
                if (deNgayDen.Text != "" && deNgayDi.Text != "")
                {
                    this.fillCbPhong();
                }
            }

        }

        private void btThem_Click(object sender, EventArgs e)
        {
            //kiem tra trung lap du lieu
            if (testPhong == true)
            {
                //them du lieu vao datatable khach hang.
                for (int i = 0; i < gvKH.RowCount; i++)
                {
                    dtKH.Rows.Add(new object[]
                  {   
                     gvKH .GetRowCellValue (i, "KH_ID"),
                     gvKH .GetRowCellDisplayText (i, gridColumnHoTen),
                     gvKH .GetRowCellDisplayText (i, gridColumnCMND),
                     gvKH .GetRowCellDisplayText (i, gridColumnDiaChi),
                     gvKH .GetRowCellDisplayText (i, gridColumnDienThoai),
                     lePhong .EditValue .ToString ()  //P_ID
                  });
                }
                //them du lieu vao datatable Phong.

                string Gia;
                if (radioGroup1.SelectedIndex == 0)
                {
                    Gia = txtGiaNgay.Text;
                }
                else
                {
                    Gia = txtGiaGio.Text;
                }
                dtPhong.Rows.Add(new object[]
                {
                lePhong.GetColumnValue("P_MA").ToString(),
                lePhong.GetColumnValue("LP_LOAI").ToString(),
                lePhong.GetColumnValue("CP_CO").ToString(),
                lePhong.GetColumnValue("KV_TEN").ToString(),
                Gia,
                lePhong.GetColumnValue("P_ID").ToString(),
                }
                    );
                gridControlChiTietDatPhong.DataSource = dtPhong;

                //gridControl1.DataSource = dtKH;

                //this.createDtKhachHang();
                testPhong = false;
            }
           
        }

        private void simpleButton1_Click_1(object sender, EventArgs e)
        {
            if (groupKH.Visible == false)
            {
                groupKH.Visible = true;
            }
            else
            {
                groupKH.Visible = false;
            }
            
        }

        private void lePhong_EditValueChanged(object sender, EventArgs e)
        {
            if (gvPhong.RowCount > 0)
            {
                for (int j = 0; j < gvPhong.RowCount; j++)
                {
                    if (gvPhong.GetRowCellValue(j, "P_ID").ToString() == lePhong.EditValue.ToString())
                    {
                        XtraMessageBox.Show("Phòng đã được đăng ký, vui lòng chọn phòng khác.");
                        //XtraMessageBox.Show(lePhong.EditValue.ToString());
                        testPhong = false;
                        break;
                    }
                    else
                    {
                        //if (radioGroup1.SelectedIndex == 0)
                        //{
                            txtGiaNgay.Text = lePhong.GetColumnValue("DG_GIA_NGAY").ToString();
                            txtGiaGio.Text = lePhong.GetColumnValue("DG_GIA_GIO").ToString();
                        //}
                        //else
                        //{
                            //txtGiaGio.Text = lePhong.GetColumnValue("DG_GIA_GIO").ToString();
                            //txtGiaNgay.Text = lePhong.GetColumnValue("DG_GIA_NGAY").ToString();
                       // }
                        groupKH.Visible = true;
                        btThemNhanhKH.Visible = true;
                        this.createDtKhachHang();
                        testPhong = true;
                    }
                }
            }
            else
            {
                testPhong = true;
                if (radioGroup1.SelectedIndex == 0)
                {
                    txtGiaNgay.Text = lePhong.GetColumnValue("DG_GIA_NGAY").ToString();
                    txtGiaGio.Text = lePhong.GetColumnValue("DG_GIA_GIO").ToString();
                }
                else
                {
                    txtGiaGio.Text = lePhong.GetColumnValue("DG_GIA_GIO").ToString();
                    txtGiaNgay.Text = lePhong.GetColumnValue("DG_GIA_NGAY").ToString();
                }
                groupKH.Visible = true;
                btThemNhanhKH.Visible = true;
                this.createDtKhachHang();
            }
        }

        private void btLuu_Click(object sender, EventArgs e)
        {
            if (radioGroup2.SelectedIndex == 0)
            {
                if (test())
                {
                    try
                    {
                        THUE_PHONG thuephong = new THUE_PHONG();
                        thuephong.NV_ID = SystemInfo.pub_NV_ID;
                        thuephong.TP_DATRA = false;
                        thuephong.TP_CHECKOUT = false;
                        //thuephong.TP_TONGCONG = Decimal.Parse(txtTraTruoc.Text);
                        
                        if (radioGroup1.SelectedIndex == 0)
                        {
                            thuephong.TP_LOAI_GIA = true;
                            thuephong.TP_NGAYBD = DateTime.Parse(deNgayDen.EditValue.ToString().Substring (0,10));
                            thuephong.TP_NGAYKT = DateTime.Parse(deNgayDi.EditValue.ToString().Substring(0, 10));
                        }
                        else
                        {
                            thuephong.TP_LOAI_GIA = false;
                            thuephong.TP_NGAYBD = DateTime.Parse(deNgayDen.EditValue.ToString());
                            thuephong.TP_NGAYKT = DateTime.Parse(deNgayDi.EditValue.ToString());
                        }

                        if (khid == "")
                        {
                            KHACH_HANG khachhang = new KHACH_HANG();
                            khachhang.KH_HOTEN = txtKhachHang.Text;
                            khachhang.KH_CMND = txtCMND.Text;
                            khachhang.KH_DIACHI = txtDiaChi.Text;
                            khachhang.KH_DIENTHOAI = txtDienThoai.Text;

                            db.KHACH_HANGs.InsertOnSubmit(khachhang);
                            thuephong.KHACH_HANG = khachhang;

                        }
                        else
                        {
                            thuephong.KH_ID = int.Parse(khid);
                        }
                        
                        //kiem tra tinh trang tra truoc
                        if  ( Decimal .Parse ( txtTraTruoc.Text) > 0)
                        {
                            DA_THANH_TOAN thanhtoan = new DA_THANH_TOAN();
                            thanhtoan.THUE_PHONG = thuephong;
                            thanhtoan.DTT_NGAY = DateTime.Today;
                            thanhtoan.DTT_SOTIEN = Decimal.Parse(txtTraTruoc.Text);
                            db.DA_THANH_TOANs.InsertOnSubmit(thanhtoan);
                        }


                        for (int i = 0; i < gvPhong.RowCount; i++)
                        {
                            CHI_TIET_THUE_PHONG chitiet = new CHI_TIET_THUE_PHONG();
                            chitiet.THUE_PHONG = thuephong;
                            chitiet.P_ID = int.Parse(gvPhong.GetRowCellValue(i, "P_ID").ToString());

                            //cap nhat trang thai cua phong
                            var phong = db.PHONGs.Single(p => p.P_ID == chitiet.P_ID);
                            phong.TT_ID = 5;



                            chitiet.CTTP_NGAYBD = DateTime.Parse(deNgayDen.EditValue.ToString());
                            chitiet.CTTP_NGAYKT = DateTime.Parse(deNgayDi.EditValue.ToString());
                            chitiet.CTTP_DONGIA = Decimal.Parse(gvPhong.GetRowCellValue(i, "GIA").ToString());
                            chitiet.CTTP_CHECKOUT = false;
                            db.CHI_TIET_THUE_PHONGs.InsertOnSubmit(chitiet);

                            foreach (DataRow dr in dtKH.Rows)
                            {

                                if (dr["P_ID"].ToString() == gvPhong.GetRowCellValue(i, "P_ID").ToString())
                                {
                                    
                                        //KHACH_HANG khTruTai = new KHACH_HANG();
                                        //khTruTai.KH_HOTEN = dr["KH_HOTEN"].ToString();
                                        //khTruTai.KH_CMND = dr["KH_CMND"].ToString();
                                        //khTruTai.KH_DIACHI = dr["KH_DIACHI"].ToString();
                                        //khTruTai.KH_DIENTHOAI = dr["KH_DIENTHOAI"].ToString();
                                        //db.KHACH_HANGs.InsertOnSubmit(khTruTai);

                                        TRU_TAI trutai = new TRU_TAI();

                                        trutai.KH_ID = int.Parse ( dr["KH_ID"].ToString()) ;
                                        trutai.CHI_TIET_THUE_PHONG = chitiet;
                                        chitiet.TRU_TAIs.Add(trutai);

                                    //db.TRU_TAIs.InsertOnSubmit(trutai );
                                }
                            }
                        }
                        db.THUE_PHONGs.InsertOnSubmit(thuephong);
                        db.SubmitChanges();
                        XtraMessageBox.Show("Bạn đã thuê phòng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Close();
                    }
                    catch (Exception)
                    {

                        XtraMessageBox.Show("Thuê phòng thất bại, vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
                //khi khach hang dat truoc
                //
                //
                //
                //

            else
            {
                //if (test())
                //{
                    try
                    {
                        THUE_PHONG thuephong = new THUE_PHONG();
                        thuephong.NV_ID = SystemInfo.pub_NV_ID;
                        thuephong.TP_DATRA = false;
                        thuephong.TP_CHECKOUT = false;
                        thuephong.TP_TONGCONG = Decimal.Parse(txtTraTruoc.Text);
                        thuephong.TP_NGAYBD = DateTime.Parse(deNgayDen.EditValue.ToString());
                        thuephong.TP_NGAYKT = DateTime.Parse(deNgayDi.EditValue.ToString());
                        if (radioGroup1.SelectedIndex == 0)
                        {
                            thuephong.TP_LOAI_GIA = true;
                        }
                        else
                        {
                            thuephong.TP_LOAI_GIA = false;
                        }

                        thuephong.KH_ID = int.Parse(leKhachHangDatTruoc.GetColumnValue("KH_ID").ToString());


                        for (int i = 0; i < gvPhong.RowCount; i++)
                        {
                            CHI_TIET_THUE_PHONG chitiet = new CHI_TIET_THUE_PHONG();
                            chitiet.THUE_PHONG = thuephong;
                            chitiet.P_ID = int.Parse(gvPhong.GetRowCellValue(i, "P_ID").ToString());

                            //cap nhat trang thai cua phong
                            var phong = db.PHONGs.Single(p => p.P_ID == chitiet.P_ID);
                            phong.TT_ID = 5;



                            chitiet.CTTP_NGAYBD = DateTime.Parse(deNgayDen.EditValue.ToString());
                            chitiet.CTTP_NGAYKT = DateTime.Parse(deNgayDi.EditValue.ToString());
                            chitiet.CTTP_DONGIA = Decimal.Parse(gvPhong.GetRowCellValue(i, "GIA").ToString());
                            chitiet.CTTP_CHECKOUT = false;
                            db.CHI_TIET_THUE_PHONGs.InsertOnSubmit(chitiet);

                            foreach (DataRow dr in dtKH.Rows)
                            {

                                if (dr["P_ID"].ToString() == gvPhong.GetRowCellValue(i, "P_ID").ToString())
                                {
                                    KHACH_HANG khTruTai = new KHACH_HANG();
                                    khTruTai.KH_HOTEN = dr["KH_HOTEN"].ToString();
                                    khTruTai.KH_CMND = dr["KH_CMND"].ToString();
                                    khTruTai.KH_DIACHI = dr["KH_DIACHI"].ToString();
                                    khTruTai.KH_DIENTHOAI = dr["KH_DIENTHOAI"].ToString();
                                    db.KHACH_HANGs.InsertOnSubmit(khTruTai);

                                    TRU_TAI trutai = new TRU_TAI();

                                    trutai.KHACH_HANG = khTruTai;
                                    trutai.CHI_TIET_THUE_PHONG = chitiet;
                                    chitiet.TRU_TAIs.Add(trutai);
                                    //db.TRU_TAIs.InsertOnSubmit(trutai );
                                }
                            }
                        }
                        db.THUE_PHONGs.InsertOnSubmit(thuephong);

                        //cap nhat lại trạng thái đặt phòng

                        DAT_PHONG datphong = db.DAT_PHONGs.Single( d => d.DP_ID == int.Parse (leKhachHangDatTruoc .EditValue .ToString ()));
                        datphong.TTDP_TRANGTHAI = "Hoàn tất";

                        db.SubmitChanges();
                        XtraMessageBox.Show("Bạn đã thuê phòng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Close();
                    }
                    catch (Exception)
                    {

                        XtraMessageBox.Show("Thuê phòng thất bại, vui lòng kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            //}
        }

        bool test()
        {
           
                if (txtKhachHang.Text == "")
                {
                    dxErrorKH.SetError(txtKhachHang, "Vui lòng nhập tên Khách Hàng.");
                    return false ;
                }
                else
                {
                    dxErrorKH.ClearErrors ();
                }

                if (txtCMND.Text == "")
                {
                    dxErrorCMND.SetError(txtCMND, "Vui lòng nhập Số CMND.");
                    return false ;
                }
                else
                {
                    dxErrorCMND.ClearErrors ();
                }
               
                if (DateTime.Parse(deNgayDen.Text) >= DateTime.Parse(deNgayDi.Text))
                {
                        dxErrorNgayDen.SetError(deNgayDen, "Ngày đến không được lớn hơn ngày đi.");
                        dxErrorNgayDi.SetError(deNgayDi, "Ngày đến không được lớn hơn ngày đi.");
                    return false ;
                }
                else
                {
                        dxErrorNgayDen.ClearErrors();
                        dxErrorNgayDi.ClearErrors();
                }


                if (gvPhong.RowCount <= 0)
                {
                    labelControl1.Visible = true;
                    labelControl1.Text = "Vui lòng nhập thông tin phòng cần đặt.";
                    timer1.Enabled = true;
                    timer1.Interval = 5000;
                    return false;
                }
            
            return true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            labelControl1.Visible = false;
        }

        private void btXoa_Click(object sender, EventArgs e)
        {
            gvPhong.DeleteSelectedRows();
        }

        private void frmDangKyThuePhong_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (testThuePhongTuQuanLyThuePhong == true )
            {
                  frmquanlythuephong.fillData();
            }
  

            if (testThuePhongtusodo == true )
            {
                 frmsodo.FillData();
            }
           
        }

        private void radioGroup2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (radioGroup2.SelectedIndex == 0)
            {
                groupControlKhachHangMoi.Visible = true;
                groupControlDatTruoc.Visible = false;
            }
            else
            {
                groupControlKhachHangMoi.Visible = false;
                groupControlDatTruoc.Visible = true;
                this.fillKhachHangDatTruoc();
            }
        }

        void fillKhachHangDatTruoc()
        {
            var khachhang = (from kh in db.DAT_PHONGs
                             where kh.DP_NGAYBD >= DateTime.Today
                                 && kh.TTDP_TRANGTHAI == "Đang chờ"
                             select new { kh.KHACH_HANG.KH_ID, kh.KHACH_HANG .KH_HOTEN ,
                                kh.KHACH_HANG .KH_CMND, kh.KHACH_HANG .KH_DIACHI , kh.KHACH_HANG .KH_DIENTHOAI , kh.DP_NGAYBD, kh.DP_ID }).Distinct();
            leKhachHangDatTruoc.Properties.DataSource = khachhang;
            leKhachHangDatTruoc.Properties.ValueMember = "DP_ID";
            leKhachHangDatTruoc.Properties.DisplayMember = "KH_HOTEN";
            leKhachHangDatTruoc.ItemIndex = 0;


        }

        private void leKhachHangDatTruoc_EditValueChanged(object sender, EventArgs e)
        {
            txtCmndDattruoc.Text = leKhachHangDatTruoc.GetColumnValue("KH_CMND").ToString ();
            txtDiaChidattruoc.Text = leKhachHangDatTruoc.GetColumnValue("KH_DIACHI").ToString ();
            txtDienThoaiDatTruoc.Text = leKhachHangDatTruoc.GetColumnValue("KH_DIENTHOAI").ToString ();

            var datphong = db.Kiem_tra_Khach_Da_Dat_phong(DateTime .Today , int.Parse ( leKhachHangDatTruoc .EditValue .ToString ()) );

            lePhong.Properties.DataSource = datphong;
            lePhong.Properties.DisplayMember = "P_MA";
            lePhong.Properties.ValueMember = "P_ID";
            lePhong.ItemIndex = 0;

            deNgayDen.EditValue = DateTime.Today;
            deNgayDen.Enabled = false;

        }

        private void gvKH_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {
            object  NewValue = e.Value;
            

            #region //Region Khách Hàng

            if (gvKH.FocusedColumn == gridColumnHoTen)
            {
                if (NewValue != null)
                {
                    gvKH.SetFocusedRowCellValue("KH_ID", NewValue);

                    //gvKH.SetFocusedRowCellValue(gridColumnHoTen, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnCMND, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnDiaChi, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnDienThoai, NewValue);
                }
            }

            if (gvKH.FocusedColumn == gridColumnCMND)
            {
                if (NewValue != null)
                {
                    gvKH.SetFocusedRowCellValue("KH_ID", NewValue);

                    gvKH.SetFocusedRowCellValue(gridColumnHoTen, NewValue);
                    //gvKH.SetFocusedRowCellValue(gridColumnCMND, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnDiaChi, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnDienThoai, NewValue);
                }
            }

            if (gvKH.FocusedColumn == gridColumnDiaChi)
            {
                if (NewValue != null)
                {
                    gvKH.SetFocusedRowCellValue("KH_ID", NewValue);

                    gvKH.SetFocusedRowCellValue(gridColumnHoTen, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnCMND, NewValue);
                    //gvKH.SetFocusedRowCellValue(gridColumnDiaChi, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnDienThoai, NewValue);
                }
            }

            if (gvKH.FocusedColumn == gridColumnDienThoai)
            {
                if (NewValue != null)
                {
                    gvKH.SetFocusedRowCellValue("KH_ID", NewValue);

                    gvKH.SetFocusedRowCellValue(gridColumnHoTen, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnCMND, NewValue);
                    gvKH.SetFocusedRowCellValue(gridColumnDiaChi, NewValue);
                    //gvKH.SetFocusedRowCellValue(gridColumnDienThoai, NewValue);
                }
            }




            #endregion
        }

        private void btThemNhanhKH_Click(object sender, EventArgs e)
        {
            frmKhachHang frmKH = new frmKhachHang();
            frmKH.frmDangKyThuePhong = this;
            frmKH.kiemtrathemnhanhThuePhong = true;
            frmKH.ShowDialog();

        }

    }
}